package five_Net.shangchuan;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        // 客户端写准备
        Socket s = new Socket("192.168.43.125", 10089);
        OutputStream os = s.getOutputStream();
        OutputStreamWriter osw = new OutputStreamWriter(os);
        BufferedWriter bw = new BufferedWriter(osw);

        // 读文件准备
        File file = new File("mian\\src\\five_Net\\shangchuan\\from.txt");
        InputStream is = new FileInputStream(file);
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);

        String line;
        while ((line = br.readLine()) != null) {
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        s.shutdownOutput();

        // 客户端读反馈
        BufferedReader brServer = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String str = brServer.readLine();
        System.out.println("Server: " + str);
        s.close();
    }
}
